<?php

/**
 * This is the model class for table "budidayamaduswadaya".
 *
 * The followings are the available columns in table 'budidayamaduswadaya':
 * @property integer $bms_id
 * @property integer $bms_kec
 * @property integer $bms_petani
 * @property integer $bms_koloni
 * @property integer $bms_pakan
 * @property integer $bms_produksi
 * @property integer $bms_tahun
 *
 * The followings are the available model relations:
 * @property Kecamatan $bmsKec
 */
class Budidayamaduswadaya extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Budidayamaduswadaya the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'budidayamaduswadaya';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('bms_kec, bms_petani, bms_koloni, bms_pakan, bms_produksi, bms_tahun', 'numerical', 'integerOnly'=>true),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('bms_id, bms_kec, bms_petani, bms_koloni, bms_pakan, bms_produksi, bms_tahun', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'bmsKec' => array(self::BELONGS_TO, 'Kecamatan', 'bms_kec'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'bms_id' => 'Bms',
			'bms_kec' => 'Bms Kec',
			'bms_petani' => 'Bms Petani',
			'bms_koloni' => 'Bms Koloni',
			'bms_pakan' => 'Bms Pakan',
			'bms_produksi' => 'Bms Produksi',
			'bms_tahun' => 'Bms Tahun',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('bms_id',$this->bms_id);
		$criteria->compare('bms_kec',$this->bms_kec);
		$criteria->compare('bms_petani',$this->bms_petani);
		$criteria->compare('bms_koloni',$this->bms_koloni);
		$criteria->compare('bms_pakan',$this->bms_pakan);
		$criteria->compare('bms_produksi',$this->bms_produksi);
		$criteria->compare('bms_tahun',$this->bms_tahun);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}